﻿
@{
    ViewBag.Title = "采购单查询";
    Layout = "~/Views/Shared/_Form.cshtml";
    var from = (ViewBag.from as string) ?? "";
}
<style>
    .table-responsive {
        border: 0;
    }

    .ui-jqgrid .ui-jqgrid-pager .ui-pager-table {
        width: 90%;
    }
</style>

<div class="topPanel" style="border-bottom:1px solid rgb(221, 221, 221);margin-bottom: 1%;">
    <div class="search">
        <table class="form">
            <tr>
                <th class="formTitle">订单编号：</th>
                <td class="formValue">
                    <input id="txt_ddbh" name="txt_ddbh" type="text" class="form-control form-an" placeholder="请输入订单编号" />
                </td>
                <th class="formTitle">订单时间：</th>
                <td class="formValue" colspan="3">
                    <input id="kssj" type="text" class="form-control input-wdatepicker" style="width:42%; margin-top:10px;float:left;" value="@DateTime.Now.AddMonths(-6).ToString("yyyy-MM-dd")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />
                    <span style="margin-left:1%;float:left">—</span>
                    <input id="jssj" type="text" class="form-control input-wdatepicker" style="width:43%; margin-top:10px;float:left;margin-left:1%;" value="@DateTime.Now.ToString("yyyy-MM-dd")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />
                </td>
                <td style="padding-left: 20px;">
                    <button type="button" id="btn_search" class="btn btn-primary btn-md">&nbsp;查询&nbsp;</button>
                </td>
            </tr>
        </table>
    </div>
</div>
<!--患者信息 包括病历号  姓名 -->
<form id="formPatSer" style="margin:2px;margin-top:10px;">
    <div class="gridPanel">
        <table id="GridList" rel="formPatSer"></table>
        <div id="gridPager" style="padding-right:20%"></div>
    </div>
</form>

<script>
    //上一个window对象
    var prevWindow;
    if ('@(from)' !== '') {
        prevWindow = top.top.frames['@(from)'];
    }
    else {
        prevWindow = $.currentWindow();
    }

    $(function () {

        var obj = new Object;
        //obj.ddbh = $.request("ddbh");
        var searInfo = new gridList();
        //加载数据
        //searInfo.init(obj);



        //查询
        $("#btn_search").click(function () {
            $("#GridList").jqGrid('setGridParam', {
                postData: {
                      kssj: $("#kssj").val(), jssj: $("#jssj").val(),ddzt:2
                },
                page: 1,
                url: "/PurchaseManage/Purchase/GetPurchaseGridJson",
            }).trigger('reloadGrid');
        });
    });

    function gridList() {
        var $gridList = $("#GridList");
        $gridList.dataGrid({
            url: "/PurchaseManage/Purchase/GetPurchaseGridJson",
            height: $(window).height() - 200,
            postData: { kssj: $("#kssj").val(), jssj: $("#jssj").val(),ddzt:2 },
            colModel: [

                { label: 'cgId', name: 'cgId', hidden: true },
                { label: '订单时间', name: 'ddsj', width: 60, align: 'left' },
                {
                    label: '配送点', name: 'psdbm', width: 120, align: 'left', formatter: function (cellvalue) {
                        return "上海明德五官科医院";
                    }
                },
                {
                    label: '订单类型', name: 'ddlx', width: 80, align: 'left', formatter: function (cellvalue) {
                        if (cellvalue == 1) return '医院自行订单';
                        else if (cellvalue == 2) return '托管药库订单';
                        else if (cellvalue == 3) return '特需药品订单';
                        else return '';
                    }
                },
                { label: '订单编号', name: 'ddbh', width: 60, align: 'left' },
                { label: '医院计划单号', name: 'yyjhdh', width: 60, align: 'left' },
                { label: '最晚到货日期', name: 'zwdhrq', width: 60, align: 'left' },
                {
                    label: '订单状态', name: 'ddzt', width: 60, align: 'left', formatter: function (cellvalue) {
                        //if (cellvalue == 1) return '保存';
                        //else if (cellvalue == 3) return '提交';
                        //else if (cellvalue == 5) return '撤回';
                        //else if (cellvalue == 7) return '作废';

                        if (cellvalue == 1) return '已保存';
                        else if (cellvalue == 2) return '已传报';
                        else if (cellvalue == 3) return '已验收';
                        else return '';
                    }
                },
                { label: '明细记录数', name: 'jls', width: 80, align: 'left' },
                { label: 'yfbm', name: 'yfbm', hidden: true },
                { label: 'bqbm', name: 'bqbm', hidden: true },

            ],

            multiselect: false,

            pager: "#gridPager",
            sortname: 'CreateTime',
            viewrecords: true,
            ondblClickRow: function (rowid, iRow, iCol, e) {
                SearchConfirm();
            }
        });
    }

    //jqGrid 双击选中某行
    function btn_edit() {
        SearchConfirm();
    }

    function PurchaseDbGrid() {
        var $gridList = $("#GridList");
        var cgId = $gridList.jqGridRowValue().cgId;
        var obj = new Object();
        obj.cgId = cgId;
        obj.ddsj = $gridList.jqGridRowValue().ddsj;
        obj.czlx = $gridList.jqGridRowValue().czlx;
        obj.yybm = $gridList.jqGridRowValue().yybm;
        obj.psdbm = $gridList.jqGridRowValue().psdbm;
        obj.ddlx = $gridList.jqGridRowValue().ddlx;
        obj.ddbh = $gridList.jqGridRowValue().ddbh;
        obj.yyjhdh = $gridList.jqGridRowValue().yyjhdh;
        obj.zwdhrq = $gridList.jqGridRowValue().zwdhrq;
        obj.jls = $gridList.jqGridRowValue().jls;
        obj.ddzt = $gridList.jqGridRowValue().ddzt;
        prevWindow.GetQueryAjax(obj);
        //关闭窗口
        ReceiptCancle();
    }
    //确定 主页面调用
    function SearchConfirm() {
        PurchaseDbGrid();
    }

    //取消
    function ReceiptCancle() {
        $.modalClose();
    }
</script>


